<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
$this->load->helper('url');
?>	<table id="tt" class="easyui-datagrid"></table>
	
	
	<div id="tb" style="padding:10px;5px;height:auto">
		<div>
			编号: <input id="id" class="easyui-textbox" style="width:80px">
			用户名: <input id="username" class="easyui-textbox" style="width:100px">
			日期 从: <input class="easyui-datebox" id="start" style="width:100px">
			到: <input class="easyui-datebox" id="end" style="width:100px">
			状态：
			<select id="status" class="easyui-combobox">
				<option value="-1">全部</option>
				
<?php
foreach ($status as $k => $v) {
?>				<option value="<?php echo $k;?>"><?php echo $v;?></option>
				<?php
}

?>			</select>
			币种：
			<select id="coin_id" class="easyui-combobox" style="width:100px">
				<option value="0">全部</option>
				
<?php
foreach ($coins as $v) {
?>				<option value="<?php echo $v['id'];?>"><?php echo $v['cn_name'];?></option>
				<?php
}

?>			</select>
			<a href="#" onclick="doSearch()" class="easyui-linkbutton" iconCls="icon-search">搜索</a>
		</div>
		<div style="margin-top:10px">
			<!-- <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" id="add">添加</a> -->
			<a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true" id="del">删除</a>
		</div>
	</div>
	<div id="win"></div>

<script language="javascript">

$(function(){
	$('#tt').datagrid({
		url:'<?php echo site_url('push/data');?>',
		pagination:true,
		pageSize:20,
		toolbar:'#tb',
		checkbox:true,
		fit:true,
		border:false,
		idField:'id',
		'columns':[[
			{field:'ck',checkbox:'true'},
			{field:'id',width:'7%',title:'编号'},
			{field:'coin_name',width:'10%',title:'币种'},
			{field:'to_uid',width:'10%',title:'接收放UID'},
			{field:'to_name',width:'10%',title:'接收方姓名'},
			{field:'amount',width:'10%',title:'转币数量'},
			{field:'total',width:'10%',title:'总金额'},
			{field:'username',width:'10%',title:'发布者帐号'},
			{field:'add_time',width:'10%',title:'发布时间'},
			{field:'status_name',width:'10%',title:'状态'},
			{field:'action',width:'10%',title:'操作',formatter:function(value,row,index){
				$s = '<a href="javascript:doedit('+row.id+')" iconCls="icon-edit" class="list_link easyui-linkbutton">修改</a>';
				$s = '----';
				return  $s;
			}},
		]],
		onLoadSuccess:function(data){$(".list_link").linkbutton()}
	});

	$('#win').window({
		width:"100%",
		height:"100%",
		modal:true,
		closed:true,
		title:'添加/修改'
	});

	$('#add').click(function(){
		$('#win').window('open');
		$('#win').window('refresh', '<?php echo site_url('push/add');?>');
	});

	$('#del').click(function(){
		var rows = $('#tt').datagrid('getChecked');
		if(rows.length == 0){  
			$.messager.alert('Info','请至少选择一行数据！','info');
			return false;  
		}

		var ids = [];
		$.each(rows,function(index,item){
			ids.push(item.id);
		});
		
		$.messager.confirm('确认信息','您确定要删除吗？删除之后不能恢复',function(r){
			if(r){
				$.getJSON('<?php echo site_url('push/del');?>',{'id[]':ids},function(d){
					$.messager.alert('信息提示',d.msg,'info');
					
					if(d.error == 0){
						$('#tt').datagrid('reload');
					}
				});
			}
		});
		
	});
});
function doSearch(){
	$('#tt').datagrid('load',{
		id: $('#id').val(),
		username: $('#username').val(),
		start: $('#start').val(),
		end: $('#end').val(),
		status: $('#status').val(),
		coin_id: $('#coin_id').val()
	});
}
function doedit(id){
	$('#win').window('open');
	$('#win').window('refresh', '<?php echo site_url('push/edit/\'+id+\'');?>');
}
</script>